//
//  VideoViewController.m
//  XYG播放器Demo
//
//  Created by 夏阳光 on 16/5/3.
//  Copyright © 2016年 夏阳光. All rights reserved.
//

#import "VideoViewController.h"
#import "KrVideoPlayerController.h"
#import "HomeModel.h"

@interface VideoViewController ()
@property (nonatomic,assign) BOOL statusHide;
@property (nonatomic,strong) KrVideoPlayerController* player;

@end

@implementation VideoViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    //初始化播放器
    self.player = [[KrVideoPlayerController alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, CGRectGetWidth(self.view.frame)*(9.0/16.0)) data:self.dataArr index:self.index];//初始化播放器
    __weak typeof(self)weakSelf = self;
    [self.player setDimissCompleteBlock:^{
        weakSelf.player = nil;
    }];
    [self.player setWillBackOrientationPortrait:^{//进入最小化状态
        weakSelf.statusHide = NO;
        [weakSelf setNeedsStatusBarAppearanceUpdate];
        [weakSelf.navigationController setNavigationBarHidden:NO animated:NO];
    }];
    [self.player setWillChangeToFullscreenMode:^{//进入全屏
        
        weakSelf.statusHide = YES;
        [weakSelf setNeedsStatusBarAppearanceUpdate];//更新状态栏样式
        [weakSelf.navigationController setNavigationBarHidden:YES animated:NO];//隐藏导航栏
    }];
    [self.view addSubview:self.player.view];
    
    
    
    HomeModel *model=self.dataArr[_index];
    self.player.contentURL=[NSURL URLWithString:model.video_url];
    [self.player prepareToPlay];
    
}

-(BOOL)prefersStatusBarHidden
{
    return self.statusHide;
}






@end
